public class Main {
    public static void main(String[] args) {
        MyBlockingQueue myBlockingQueue = new MyBlockingQueue();
        Thread customer = new Thread(()-> {
           while (true) {
               try  {
                   System.out.println("消费了: "+myBlockingQueue.take());
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        });
        customer.start();
        new Thread(()->{
            for (int i = 1;i <= 50 ;i++) {
                try {
                    myBlockingQueue.put(i);
                    System.out.println("生产了: " + i);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }
}
